#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 4e3 + 10;
const int MOD = 1e9 + 7;

int t, n;
vector<int> g[MAXN];

int white[MAXN], black[MAXN];
string s;

void dfs(int u, int fa = -1) {
    if (s[u] == 'W') white[u] = 1;
    else black[u] = 1;

    for (auto v : g[u]) {
        if (v != fa) {
            dfs(v, u);
            white[u] += white[v];
            black[u] += black[v];
        }
    }
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 1; i <= n; i++) g[i].clear(), white[i] = black[i] = 0;
        for (int i = 2; i <= n; i++) {
            int fa;
            cin >> fa;
            g[fa].push_back(i);
            white[i] = black[i] = 0;
        }
        cin >> s;
        s = "%" + s;

        dfs(1);

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (white[i] == black[i]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}